<?php defined('SYSPATH') or die('No direct access allowed.');

class Helper_Signalreader {
	
	//se chequea la integridad de todo un archivo o de una muestra en particular?
	public static function checkIntegrity($filename){}
	
	public static function deleteFile($filename){
	}
	
	public static function exists($filename){
	}
	
	public static function getFromDatabase($signal_id){}
	
	//returns a segment
	public static function getFromFile($filename){
		//check integrity
		$segment = Model::factory("segment");
		$segment->setSamples($this->openFile($filename)); 
		return $segment;
	}
	
	public static function getFromJSON($json){
		
	}
	

	public static function openFile($filename){
		$samples = array();
		$fp=fopen($filename,"r");
		while(!feof($fp)){
			$samples[] = fgets($fp);
		}
		fclose($fp);
		return $samples;
	}
	
	public static function saveToFile($segment, $filename){
		
	}
	
	
	
	

}
